package ninja.awesome.game.gameobject;

import java.util.Random;

import ninja.awesome.framework.Graphics;
import ninja.awesome.framework.Image;
import ninja.awesome.game.MainGameScreen;
import ninja.awesome.game.MainGameScreen.PlayingMode;
import ninja.awesome.game.classes.Neutral;
import ninja.awesome.game.compat.Rectangle;
import ninja.awesome.game.main.Controller;
import ninja.awesome.game.main.Physics;
import ninja.awesome.game.main.Sprites;

public class Items extends GameObj implements Neutral {

	private Image image;
	private int speed = 1;
	MainGameScreen game;
	Sprites s;
	Controller c;
	private int type;
	private long Timer;
	private long Delay;

	public Items(String ref, int xLoc, int yLoc, int speed, int type, MainGameScreen game, Controller c, Sprites s) {
		super(xLoc, yLoc);
		this.type = type;
		this.Timer = System.nanoTime();
		this.Delay = 10000L;
		this.game = game;
		this.c = c;
		this.s = s;
		image = s.getLife();

	}

	@Override
	public void draw(Graphics g) {
		// g.drawImage(this.image, getxLoc(),
		// getyLoc(), null);
	}

	@Override
	public Rectangle getBounds() {
		return new Rectangle(xLoc, yLoc, 16, 16);
	}

	public boolean remove() {
		long elapsed = (System.nanoTime() - this.Timer) / 1000000L;
		if (elapsed > this.Delay) {
			return true;
		}
		return false;
	}

	@Override
	public void update() {

		yLoc += speed;
		if (game.getPlayingMode() == PlayingMode.SINGLE) {
			if (Physics.collision(this, game.getNinja())) {
				game.getNinja().setHEALTH(game.getNinja().getHEALTH() + 0);
				c.removeNeutral(this);

			}
		}

	}

	public static int randomInt(int min, int max) {
		Random rand = new Random();
		int randomNum = rand.nextInt(max - min + 1) + min;
		return randomNum;
	}

	public int getType() {
		return this.type;
	}

	@Override
	public int getX() {

		return xLoc;
	}

	@Override
	public int getY() {

		return yLoc;
	}

}
